
capture log close

set matsize 5000


use "Data/BerkesGooglePatentDatabase/cit_received_long.dta", clear

gen citationcounter = 1
collapse (sum) citationcounter, by(patnum)

save "Data/BerkesGooglePatentDatabase/citationcounts.dta", replace


use "Data/control_classes_CW.dta", clear
append using "Data/control_classes_WWI.dta"
merge 1:1 patnum using "Data/all_patents_basicinfo.dta"
keep if _merge == 3
drop _merge

merge 1:1 patnum using "Data/BerkesGooglePatentDatabase/citationcounts.dta"

tab _merge
drop if _merge == 2
drop _merge

replace citationcounter = 0 if citationcounter == .


gen prosthetics = 0
replace prosthetics = 1 if nclassgoogle1 == 623
gen patentcount = 1
gen anycites = 0
replace anycites = 1 if citationcounter > 0 & citationcounter != .
collapse (sum) patentcount anycites citationcounter (mean) meancitations = citationcounter, by(prosthetics iyear)
rename iyear year
tsset prosthetics year
tsfill, full


// Appendix Figure D.4, Panel B: Mean Citations Per Patent
twoway (tsline meancitations if year > 1911 & year < 1930 & prosthetics == 1, xline(1916, lcolor(black) lpattern(dash)) xline(1923, lcolor(black) lpattern(dash)) lwidth(medthick)) (tsline meancitations if year > 1911 & year < 1930 & prosthetics != 1, yaxis(2) lpattern(dash) lwidth(medthick)), ytitle(Prosthetic Patents) ytitle(All Other Patents, axis(2)) title(Mean Citations Per Patent During the World War I Era, color(black)) ylabel(0(1)5) ylabel(0(1)5, axis(2)) xlabel(1910(5)1930) legend(label(1 "Prosthetics") label(2 "All Other")) graphregion(fcolor(white)) scale(0.9) name(LimbsAndControlsWWIMeanCits, replace) 
graph export "Figures/LimbsAndControlsWWIMeanCits.pdf", name(LimbsAndControlsWWIMeanCits)  replace

// Appendix Figure D.4, Panel A: Mean Citations Per Patent
twoway (tsline meancitations if year >= 1855 & year <= 1875 & prosthetics == 1, xline(1862, lcolor(black) lpattern(dash)) xline(1867, lcolor(black) lpattern(dash)) lwidth(medthick)) (tsline meancitations if year >= 1855 & year <= 1875 & prosthetics != 1, yaxis(2) lpattern(dash) lwidth(medthick)), ytitle(Prosthetic Patents) ytitle(All Other Patents, axis(2)) title(Mean Citations To Civil War Era Patents, color(black)) ylabel(0(0.25)1) ylabel(0(0.25)1, axis(2)) xlabel(1855(5)1875) legend(label(1 "Prosthetics") label(2 "All Other")) graphregion(fcolor(white)) scale(0.9) name(LimbsAndControlsCivilWarMeanCits, replace) 
graph export "Figures/LimbsAndControlsCivilWarMeanCits.pdf", name(LimbsAndControlsCivilWarMeanCits)  replace


